#include "SelectionSort.h"
using namespace std;
SelectionSort::SelectionSort(long v[], long n)
{
    for (long i = 0; i < n; ++i)
        this -> array[i] = v[i];
}
void SelectionSort::sort(long n)
{
    long k, aux;
	for (long i = 0; i < n - 1; ++i)
	{
		k = i;
        for (long j = i + 1; j < n; ++j)
			if (this -> array[k] > this -> array[j])
				k = j;
        if (k != i)
		{
			aux = this -> array[k];
            this -> array[k] = this -> array[i];
            this -> array[i] = aux;
		}
	}
}
double SelectionSort::getExecutionTime(long n)
{
    clock_t start, end;
    start = clock();
    this -> sort(n);
    end = clock();
    return (double)(end - start) / CLOCKS_PER_SEC;
}
bool SelectionSort::Check(long n)
{
	long i;
	bool  ok = true;
	for (i = 0; i < n - 1; ++i)
		if (this -> array[i] > this -> array[i + 1])
		{
			ok = false;
			break;
		}
	cout << "\t" << i;
	return ok;
}

